<!DOCTYPE html>
<html>
<head lang="zh-CN">
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="keywords" content="">
<meta name="description" content="">
<meta name="format-detection" content="telephone=no, email=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" href="<%=basePath%>favicon.ico" />

<title>购物车</title>
<!--标准mui.css-->
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>plugins/mui/css/mui.min.css">

<link rel="stylesheet" href="<%=basePath%>css/common/iconfont.css">
<link rel="stylesheet" href="<%=basePath%>css/common/normalize.css">
<link rel="stylesheet" href="<%=basePath%>/css/cart/cart.css">

<script src="<%=basePath%>dist/js/jquery.js"></script>
<script src="<%=basePath%>plugins/mui/js/mui.min.js"></script>

</head>
<body>
	<div class="m-wrapper">
		<jsp:include page="header_member.jsp"></jsp:include>
		<div id="box-main" class="m-main m-cart box-tab">
			<div class="cart_box">
				<div class="cart_bd">
					<ul class="m-list clear-fix">
						<c:choose>
							<c:when test="${empty car}">
								<li style="width: 100%;">你的购物车是空的</li>
							</c:when>
							<c:otherwise>
								<c:forEach items="${car}" var="car">
									<li name="carli">
										<dl>
											<dd>
												<a
													href="<%=basePath%>mobile/goodsdetail?id=${car.goods_id}">
													<img class="lazy" src="<%=imagePath%>${car.goods.image}"
													alt="">
												</a>
											</dd>
											<dd>
												<div class="product-note">${car.goods.name}<br />${car.product.pdt_spec}</div>
												<div class="product-price">
													&yen;
													<fmt:formatNumber value="${car.product.price*car.count}"
														pattern="#0.00" />
													<span style="float: right">X ${car.count}</span>
												</div>
											</dd>
										</dl>
										<div class="clear"></div>
									</li>
								</c:forEach>
							</c:otherwise>
						</c:choose>
					</ul>
					<div class="product-loading tc_loading">加载中</div>
				</div>
			</div>
			<!--热销产品:end-->
		</div>
		<!--正文:end-->
		<div id="box-footer" class="m-footer fixed-box">
			<button type="button" class="btn_confirm" onclick="topay()">确认支付</button>
		</div>

		<form action="<%=basePath%>mobile/confirmCar" id="topayorder"
			style="display: none;">
			<input name="carids" id="carids">
		</form>
	</div>

	<jsp:include page="footerNav.jsp"></jsp:include>
	<!--底部:end-->

	<div id="mask"></div>
	<script type="text/javascript"
		src="<%=basePath%>js/zepto.min.js-v=201601281128"></script>
	<script type="text/javascript"
		src="<%=basePath%>js/util.js-v=201601281128"></script>
	<script type="text/javascript"
		src="<%=basePath%>js/head.js-v=201601281128"></script>
	<script type="text/javascript"
		src="<%=basePath%>js/extend/swiper.min.js-v=201601281128"></script>
	<script>
		$(function(){
			$("#header_title").html("购物车");
		});
		
		function allselect() {
			var checkboxs = document.getElementsByName("carcheckbox");
			if (true == $("#allselect").is(":checked")) {
				for (var i = 0; i < checkboxs.length; i++) {
					var e = checkboxs[i];
					e.checked = true;
				}
			} else {
				for (var i = 0; i < checkboxs.length; i++) {
					var e = checkboxs[i];
					e.checked = false;
				}
			}
		}

		function cleanCar() {
			var carids = new Array();
			$("input[name='carcheckbox']").each(function() {
				carids.push($(this).val());
			})
			if (carids.length == 0) {
				alert("没有删除的商品");
				return;
			}
			deleteCar(carids.join(","));
		}

		function delCar() {
			var carids = new Array();
			$("input[name='carcheckbox']:checked").each(function() {
				carids.push($(this).val());
			})
			if (carids.length == 0) {
				alert("请选择要删除的商品");
				return;
			}
			deleteCar(carids.join(","));
		}
		
		function deleteCar(cids){
			$.ajax({
				type:"post",
				url:"../mobile/deleteCar",
				data : "c_ids=" + cids,
				success : function(msg) {
					var info = eval('(' + msg + ')');
					alert(msg.information);
				}
			})
		}

		function topay() {
			alert($("li[name='carli']").length);
			/* var carids = new Array();
			$("input[name='carcheckbox']:checked").each(function() {
				carids.push($(this).val());
			})
			if (carids.length == 0) {
				alert("请选择要支付的商品");
				return;
			}
			$("#carids").val(carids.join(",")); */
			/* $("#topayorder").submit(); */
		}
	</script>
</body>
</html>

